
def get_auth_url():
    """
        client_id   必填  string  申请应用时分配的App Key。
        redirect_uri    必填  string  授权回调地址，站外应用需与设置的回调地址一致。
    """
    weibo_auth_url = 'https://api.weibo.com/oauth2/authorize'
    redirect_uri = "http://127.0.0.1:8000/complete/weibo/"
    client_id = '29447*****'
    auth_url = weibo_auth_url + "?client_id={client_id}&redirect_uri={re_url}".format(client_id=client_id,re_url=redirect_uri)                                                                 
    print(auth_url)


def get_access_token(code):
    access_token_url = "https://api.weibo.com/oauth2/access_token"
    import requests
    re_dict = requests.post(access_token_url, data={
        "client_id": "29447*****",
        # App Secret
        "client_secret": "3500dfe8e580c20dfec9828*********",
        "grant_type": "authorization_code",
        "code": code,
        "redirect_uri": "http://127.0.0.1:8000/complete/weibo/",

    })
    pass


def get_user_info(access_token):
    user_url = "https://api.weibo.com/2/users/show.json"
    uid = "5020302235"
    get_url = user_url+"?access_token={at}&uid={uid}".format(at=access_token,uid=uid)
    print(get_url)

if __name__ == '__main__':

    get_user_info(access_token='**********2892e8c6shqQsB')